#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Project  : ecshop
# @File     : page_backend_delete_discount.py
# @Author   : WanLiWei
# @Time     : 2021/7/3 15:13
class PageBackendDeleteDiscount():
    def __init__(self,driver):
        self.driver=driver
    def test_click_promotion(self):
        # 进入id为menu-frame的frame
        self.driver.switch_to.frame('menu-frame')
        # 点击促销管理
        self.driver.find_element_by_xpath('//ul[@id="menu-ul"]/li[2]').click()
    def test_click_discount(self):
        # 点击优惠活动
        self.driver.find_element_by_xpath('//ul[@id="menu-ul"]/li[2]/ul/li[8]/a').click()
        # 退出frame
        self.driver.switch_to.default_content()
    def test_click_delete(self):
        # 进入id为main-frame的frame
        self.driver.switch_to.frame('main-frame')
        # 点击移除按钮
        self.driver.find_element_by_xpath('//div[@id="listDiv"]/table[1]/tbody/tr[2]/td[8]/a[2]/img').click()
    def test_click_confirm(self):
        # 弹框点确定
        self.driver.switch_to.alert.accept()
        # 退出frame
        self.driver.switch_to.default_content()

    def test_discount(self):
        self.test_click_promotion()
        self.test_click_discount()
        self.test_click_delete()
        self.test_click_confirm()